package com.lingyu.jsjx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lingyu.jsjx.domain.SocialService;
import com.lingyu.jsjx.service.ISocialServiceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 社会服务档案Controller
 * 
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/socialService")
public class SocialServiceController extends BaseController
{
    @Autowired
    private ISocialServiceService socialServiceService;

    /**
     * 查询社会服务档案列表
     */
    @RequiresPermissions("jsjx:socialService:list")
    @GetMapping("/list")
    public TableDataInfo list(SocialService socialService)
    {
        startPage();
        List<SocialService> list = socialServiceService.selectSocialServiceList(socialService);
        return getDataTable(list);
    }

    /**
     * 导出社会服务档案列表
     */
    @RequiresPermissions("jsjx:socialService:export")
    @Log(title = "社会服务档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SocialService socialService)
    {
        List<SocialService> list = socialServiceService.selectSocialServiceList(socialService);
        ExcelUtil<SocialService> util = new ExcelUtil<SocialService>(SocialService.class);
        util.exportExcel(response, list, "社会服务档案数据");
    }

    /**
     * 获取社会服务档案详细信息
     */
    @RequiresPermissions("jsjx:socialService:query")
    @GetMapping(value = "/{serviceId}")
    public AjaxResult getInfo(@PathVariable("serviceId") Long serviceId)
    {
        return success(socialServiceService.selectSocialServiceByServiceId(serviceId));
    }

    /**
     * 新增社会服务档案
     */
    @RequiresPermissions("jsjx:socialService:add")
    @Log(title = "社会服务档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SocialService socialService)
    {
        return toAjax(socialServiceService.insertSocialService(socialService));
    }

    /**
     * 修改社会服务档案
     */
    @RequiresPermissions("jsjx:socialService:edit")
    @Log(title = "社会服务档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SocialService socialService)
    {
        return toAjax(socialServiceService.updateSocialService(socialService));
    }

    /**
     * 删除社会服务档案
     */
    @RequiresPermissions("jsjx:socialService:remove")
    @Log(title = "社会服务档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceIds}")
    public AjaxResult remove(@PathVariable Long[] serviceIds)
    {
        return toAjax(socialServiceService.deleteSocialServiceByServiceIds(serviceIds));
    }
}
